﻿using System;

namespace MMonitor.PM6750
{
    public class ReceivedDataModelV2:DataModel
    {
        public ReceivedDataModelV2()
        {
            ECGWaveData1 = new ECGWaveData();
            ECGParamsData1 = new ECGParamsData();
            NIBPData1 = new NIBPData();
            SPO2Data1 = new SPO2Data();
            TemperatureData1 = new TemperatureData();
            KeysState1 = new KeysStateData();
            SoftwareVersion = "";
            HardwareVersion = "";
            SATWaveData = 0;
            RESPWaveData = 0;
        }
        /// <summary>
        /// 心电波形数据
        /// </summary>
        public ECGWaveData ECGWaveData1;
        /// <summary>
        /// 心电参数数据
        /// </summary>
        public ECGParamsData ECGParamsData1;
        /// <summary>
        /// 无创血压数据
        /// </summary>
        public NIBPData NIBPData1;
        /// <summary>
        /// 血氧数据
        /// </summary>
        public SPO2Data SPO2Data1;
        /// <summary>
        /// 体温数据
        /// </summary>
        public TemperatureData TemperatureData1;
        /// <summary>
        /// 软件版本号
        /// </summary>
        public string SoftwareVersion;
        /// <summary>
        /// 硬件版本
        /// </summary>
        public string HardwareVersion;
        /// <summary>
        /// 血氧波形数据--血氧体积描记波的幅值数据，范围0~100
        /// </summary>
        public byte SATWaveData;
        /// <summary>
        /// 呼吸波形数据--呼吸波的幅值数据，范围0~250
        /// </summary>
        public byte RESPWaveData;

        public KeysStateData KeysState1;

        #region 数据类声明
        public class ECGWaveData
        {
            //四个个导联值，数值范围0~250
            public byte LeadData1 = 0;
            public byte LeadData2 = 0;
            public byte LeadData3 = 0;
            public byte LeadData4 = 0;

            public ECGWaveData()
            {
                LeadData1 = 0; LeadData2 = 0; LeadData3 = 0; LeadData4 = 0;
            }

            public ECGWaveData(byte d1, byte d2, byte d3, byte d4)
            {
                LeadData1 = d1; LeadData2 = d2; LeadData3 = d3; LeadData4 = d4;
            }
        }
        public class ECGParamsData
        {
            public string ECGSignalQuality;//心电信号强度
            public string ECGCurrentLead;//心电当前数据对应的导联
            public string ECGCurrentLeadMode;//心电当前数据对应的导联
            public string ECGLeadState;//心电导联模式
            public string ECGFilteringMode;//心电滤波模式
            public string ECGGain;//心电模块增益
            public byte HeartRate;//心率值
            public byte BreathRate;//呼吸率
            public decimal STPotential;//ST电位
            public string ECGAbnormalCode;//心率异常代码 

            public ECGParamsData()
            {
                ECGSignalQuality = EnumECGSignalQuality.正常.ToString();
                ECGCurrentLead = EnumECGLeadChioced.Ⅰ.ToString();
                ECGLeadState = EnumECGLeadState.正常.ToString();
                ECGFilteringMode = EnumECGFilteringMode.监护模式.ToString();
                ECGGain = EnumECGGain.X05.ToString();
                HeartRate = 0;
                BreathRate = 0;
                STPotential = 0;
                ECGAbnormalCode = EnumECGAbnormalCode.正常.ToString();
            }
            /// <summary>
            /// 带参构造函数
            /// </summary>
            /// <param name="sq1">心电信号强度</param>
            /// <param name="cl1">心电当前的导联模式</param>
            /// <param name="ls1">心电导联模式</param>
            /// <param name="fm1">心电滤波模式</param>
            /// <param name="g1">心电模块增益</param>
            /// <param name="hr">心率值</param>
            /// <param name="br">呼吸率</param>
            /// <param name="stp">ST电位</param>
            /// <param name="ac1">心率异常代码</param>
            public ECGParamsData(int sq1, int cl1, int ls1, int fm1, int g1, byte hr, byte br, decimal stp, int ac1)
            {
                ECGSignalQuality = Enum.GetName(typeof (EnumECGSignalQuality),sq1);
                ECGCurrentLeadMode = Enum.GetName(typeof (EnumECGCurrentLeadMode),cl1);
                ECGLeadState = Enum.GetName(typeof(EnumECGLeadState), ls1);
                ECGFilteringMode = Enum.GetName(typeof (EnumECGFilteringMode), fm1);
                ECGGain = Enum.GetName(typeof (EnumECGGain), g1);
                ECGAbnormalCode = Enum.GetName(typeof (EnumECGAbnormalCode), ac1);
                HeartRate = hr;
                BreathRate = br;
                STPotential = stp;
            }
        }
        public class NIBPData
        {
            /// <summary>
            /// 无创血压测量模式
            /// </summary>
            public string NIBPTestMode;
            /// <summary>
            /// 无创血压自动测量方式
            /// </summary>
            public string NIBPTestType;
            /// <summary>
            /// 无创血压测量状态
            /// </summary>
            public string NIBPTestState;
            /// <summary>
            /// 袖带压  实际值=袖带压X2,单位：mmHg（毫米汞柱）
            /// </summary>
            public byte CuffPressure;
            /// <summary>
            /// 收缩压--范围0~250，单位：mmHg（毫米汞柱）
            /// </summary>
            public byte SystolicPressure;
            /// <summary>
            /// 平均压--范围0~250，单位：mmHg（毫米汞柱）
            /// </summary>
            public byte AveragePressure;
            /// <summary>
            /// 舒张压--范围0~250，单位：mmHg（毫米汞柱）
            /// </summary>
            public byte DiastolicPressure;
            /// <summary>
            /// 无创血压脉率
            /// </summary>
            public byte PulseRate;

            public NIBPData()
            {
                NIBPTestMode = EnumNIBPTestMode.成人模式.ToString();
                NIBPTestState = EnumNIBPTestState.初始化完成.ToString();
                NIBPTestType = EnumNIBPTestType.手动测量模式.ToString();
                CuffPressure = 0;
                SystolicPressure = 0;
                AveragePressure = 0;
                DiastolicPressure = 0;
                PulseRate = 0;
            }

            public NIBPData(int ntm1, int nts1, byte natm1,byte cp1, byte sp1, byte dp1, byte ap1,byte pr1)
            {
                NIBPTestMode = Enum.GetName(typeof(EnumNIBPTestMode), ntm1);
                NIBPTestState = Enum.GetName(typeof(EnumNIBPTestState), nts1);
                NIBPTestType = Enum.GetName(typeof(EnumNIBPTestType), natm1);
                CuffPressure = cp1;
                SystolicPressure = sp1;
                DiastolicPressure = dp1;
                AveragePressure = ap1;
                PulseRate = pr1;
            }
        }
        public class SPO2Data
        {
            /// <summary>
            /// 血氧饱和度测量状态
            /// </summary>
            public string SPO2State;
            /// <summary>
            /// 血氧饱和度值 无效值为127
            /// </summary>
            public byte SPO2Value;
            /// <summary>
            /// 脉搏率 无效值为255
            /// </summary>
            public byte PulseRate;
            
            public string SignalQuality;
            public string State;

            public SPO2Data()
            {
                SPO2State = EnumSPO2State.正常.ToString();
                SPO2Value = 0;
                PulseRate = 0;
                SignalQuality = "无信号";
            }

            public SPO2Data(int sps1, byte spv1, byte pr1,string sq1)
            {
                SPO2State = Enum.GetName(typeof (EnumSPO2State), sps1);
                SPO2Value = spv1;
                PulseRate = pr1;
                SignalQuality = sq1;
            }
        }
        public class TemperatureData
        {
            public string TemperateState;
            public decimal TemperateValue1;
            public decimal TemperateValue2;

            public TemperatureData()
            {
                TemperateState = EnumTemptureState.正常.ToString();
                TemperateValue1 = 0;
                TemperateValue2 = 0;
            }

            public TemperatureData(int ets1, decimal tv1, decimal tv2)
            {
                TemperateState = Enum.GetName(typeof(EnumTemptureState),ets1);
                TemperateValue1 = 0;
                TemperateValue2 = 0;
            }
        }

        /// <summary>
        /// 按键状态值
        /// </summary>
        public class KeysStateData
        {
            /// <summary>
            /// 按键KEY0
            /// </summary>
            public bool KEY0 { get; set; }
            /// <summary>
            /// 按键KEY1
            /// </summary>
            public bool KEY1 { get; set; }
            /// <summary>
            /// 按键KEY2
            /// </summary>
            public bool KEY2 { get; set; }
            /// <summary>
            /// 按键KEY3
            /// </summary>
            public bool KEY3 { get; set; }
            /// <summary>
            /// 按键KEY4
            /// </summary>
            public bool KEY4 { get; set; }
            /// <summary>
            /// 按键KEY5
            /// </summary>
            public bool KEY5 { get; set; }
            /// <summary>
            /// 单键飞梭编码器
            /// </summary>
            public string KEY6 { get; set; }

            public KeysStateData()
            {
                KEY0 = KEY1 = KEY2 = KEY3 = KEY4 = false;
                KEY6 = Enum.GetName(typeof (DataModel.EnumKeysState), 3);
            }

            public KeysStateData(byte k0, byte k1, byte k2, byte k3, byte k4, byte k5, byte k6)
            {
                KEY0 = Convert.ToBoolean(k0);
                KEY1 = Convert.ToBoolean(k1);
                KEY2 = Convert.ToBoolean(k2);
                KEY3 = Convert.ToBoolean(k3);
                KEY3 = Convert.ToBoolean(k3);
                KEY5 = Convert.ToBoolean(k5);
                KEY6 = Enum.GetName(typeof(DataModel.EnumKeysState), k6);
            }
        }
        #endregion
    }
}
